package conMgr.ui.util;

import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JPanel;

/**
 * Provides a basic button bar implementation.
 * @author is4@uw.edu
 */
public class ButtonBar extends JPanel
{
	/**
	 * The serialization ID for this class.
	 */
	private static final long serialVersionUID = 80601484367145804L;
	
	/**
	 * Initializes a new button bar.
	 */
	public ButtonBar()
	{
		setLayout(new GridBagLayout());
		setBackground(Color.GRAY);
	}
	
	/**
	 * Adds a button to the button bar.
	 * @param caption The caption for the button.
	 * @param action The action for the button to take when clicked.
	 */
	public void addButton(final String caption, final Action action)
	{
		final JButton button = Ui.createButton(caption, action);
		final GridBagConstraints constraints = new GridBagConstraints();
		constraints.gridx = getComponentCount();
		constraints.gridy = 0;
		constraints.anchor = GridBagConstraints.WEST;
		constraints.insets = Ui.DEFAULT_INSETS;
		add(button, constraints);
	}
}
